//
// Created by longyunbo on 6/23/21.
//

#ifndef ANALYSIS_BOOTCLASSLOAD_H
#define ANALYSIS_BOOTCLASSLOAD_H
#include "../oops/InstanceKlass.h"
#include "../../tool/DataTranslate.h"
#include "../classfile/ClassFileParser.h"

using namespace std;

struct BootClassLoad {

    //前缀
    char* const SUFFIX  = ".class";

    /**
     * 类加载路径
     * */
    char* searchFile = "///home/longyunbo/temp/parse/";
    /**
    *  main函数所在的类在此保存一份引用，方便快速定位到
    */
    InstanceKlass* _mainKlass = nullptr ;

    //工具类
    DataTranslate* _dataTranslate;

    ClassFileParser* classFileParser;

    /**
     * 存放加载过的Class
     * */
    map<string,InstanceKlass*> classLoaderData;
    /**
     * map的迭代器
     * */
    map<string,InstanceKlass*> ::iterator _itclassLoaderData;

public:

    //得到InstanceKlass
    InstanceKlass*  getInstanceKlass();
    //设置InstanceKlass
    void setInstanceKlass(InstanceKlass* instanceKlass);
    //
    InstanceKlass* loadKlass(string className,bool b);



    ~BootClassLoad();

public:
    InstanceKlass* loadKlass(string name);

private:
   static void resolveKlass();
   InstanceKlass* readAndParse(string name);


};


#endif //ANALYSIS_BOOTCLASSLOAD_H
